package com.ytjj.qmyx.admin.controller;


import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.model.request.AppListRequest;
import com.ytjj.qmyx.admin.model.request.AppPlatformStrictRequest;
import com.ytjj.qmyx.admin.service.AppListManageService;
import com.ytjj.qmyx.admin.service.DynamicService;
import com.ytjj.qmyx.admin.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * app达人榜单管理
 */
@RestController
@RequestMapping("/appListManage")
@Slf4j
public class AppListManageController {

    @Autowired
    private AppListManageService appListManageService;

    @Autowired
    private UserService userService;

    @Autowired
    private DynamicService dynamicService;

    /**
     * 查询达人榜单
     */
    @PostMapping("/selectAppList")
    public CommonResult selectAppList(@RequestBody AppListRequest request){
        return CommonResult.success(appListManageService.selectAppList(request));
    }

    /**
     * 新增达人榜单
     */
    @PostMapping("/createAppList")
    public CommonResult createAppList(@RequestBody AppListRequest request){
        return CommonResult.success(appListManageService.createAppList(request));
    }

    /**
     * 编辑达人榜单
     */
    @PostMapping("/updateAppList")
    public CommonResult updateAppList(@RequestBody AppListRequest request){
        return CommonResult.success(appListManageService.updateAppList(request));
    }

    /**
     * 删除达人榜单
     */
    @GetMapping("/deleteAppList")
    public CommonResult deleteAppList(@RequestParam Integer id){
        return CommonResult.success(appListManageService.deleteAppList(id));
    }

    //------------------------------------------------------------------------------------

    /**
     * 根据榜单id查询达人
     */
    @PostMapping("/selectById")
    public CommonResult selectPlatformStrict(@RequestBody AppPlatformStrictRequest request){
        return CommonResult.success(appListManageService.selectPlatformStrict(request));
    }

    /**
     * 根据榜单id新增达人
     */
    @PostMapping("/createById")
    public CommonResult createPlatformStrict(@RequestBody AppPlatformStrictRequest request){
        return CommonResult.success(appListManageService.createPlatformStrict(request));
    }

    /**
     * 根据id编辑达人
     */
    @PostMapping("/updateById")
    public CommonResult updatePlatformStrict(@RequestBody AppPlatformStrictRequest request){
        return CommonResult.success(appListManageService.updatePlatformStrict(request));

    }

    /**
     * 根据id删除达人
     */
    @GetMapping("/deleteById")
    public CommonResult deletePlatformStrict(@RequestParam Integer id){
        return CommonResult.success(appListManageService.deletePlatformStrict(id));
    }

    /**
     * 编辑达人的收益金额和收益排行
     */
    @PostMapping("/updateSubsidy")
    public CommonResult updateSubsidy(@RequestBody AppPlatformStrictRequest request){
        return CommonResult.success(appListManageService.updatePlatformStrict(request));
    }

    /**
     * 根据用户id查昵称
     */
    @GetMapping("/selectByUserId")
    public CommonResult selectByUserId(@RequestParam Integer userId){
        return CommonResult.success(userService.selectByUserId(userId));
    }

    /**
     * 根据userId查该用户测评的商品
     */
    @GetMapping("/selectProductByUserId")
    public CommonResult selectProductByUserId(@RequestParam Integer userId){
        return CommonResult.success(dynamicService.selectProductByUserId(userId));
    }

    /**
     * 获取所有保存的达人类型
     */
    @GetMapping("/getUserType")
    public CommonResult getUserType(){
        return CommonResult.success(appListManageService.getUserType());
    }
}
